package com.czh.common.domain;

import com.czh.common.constant.ResCode;

import java.util.HashMap;

public class AjaxRes extends HashMap<String,Object> {
    public static final String CODE = "code";
    public static final String MSG = "msg";
    public static final String DATA = "data";
    public static final String KEY_TOKEN = "token";

    public static final String SUCCESS = "操作成功";
    public static final String FAULT = "操作失败";

    public static AjaxRes success () {
        AjaxRes ajaxRes = new AjaxRes();
        ajaxRes.put(CODE, ResCode.SUCCESS);
        ajaxRes.put(MSG, SUCCESS);
        return ajaxRes;
    }


    public static AjaxRes success (String msg) {
        AjaxRes ajaxRes = new AjaxRes();
        ajaxRes.put(CODE, ResCode.SUCCESS);
        ajaxRes.put(MSG, msg);
        return ajaxRes;
    }

    public static AjaxRes fault () {
        AjaxRes ajaxRes = new AjaxRes();
        ajaxRes.put(CODE, ResCode.FAULT);
        ajaxRes.put(MSG, FAULT);
        return ajaxRes;
    }
    public static AjaxRes fault (String msg) {
        AjaxRes ajaxRes = new AjaxRes();
        ajaxRes.put(CODE, ResCode.FAULT);
        ajaxRes.put(MSG, msg);
        return ajaxRes;
    }
}
